//
//  main.m
//  OC6_字典&集合课后作业
//
//  Created by dllo on 15/10/29.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Contact.h"
#import "AddressBook.h"

int main(int argc, const char * argv[]) {

    
    // 通讯录
    
    Contact *c1 = [[Contact alloc] initWithName:@"ZhangSan" sex:@"男" phonenum:1233242 address:@"南沙" group:@"朋友" age:25];
    
    NSMutableArray *value = [NSMutableArray array];
    NSMutableArray *key = [[NSMutableArray alloc] initWithObjects:@"A", @"B", @"C", @"D",@"E", @"F", @"G", @"H", @"I", @"J", @"K", @"L", @"M", @"N", @"O", @"P", @"Q", @"R", @"S", @"T", @"U", @"V", @"W", @"X", @"Y", @"Z", nil];
    NSMutableDictionary  *dic = [[NSMutableDictionary alloc] init];
   
    
    for (NSInteger i = 0 ; i < 26; i++) {
        [dic setObject:value forKey:[key objectAtIndex:i]];
    }
    // 查看字典定义没有
    for (NSString *key in dic) {
        NSLog(@"%@", key);
    }
    NSLog(@"%ld", dic.count);
    
    //3、可以添加联系人对象，如果姓名或电话号码为空，添加失败。添加联系人到匹配的分组。
    

    [dic setObject:c1 forKey:[[c1 name] substringFromIndex:1]];

    
    
    
//    // color
////    
//    NSString *filePath = @"/Users/dllo/Desktop/DLS151034/OC6_字典&集合/OC6_字典&集合课后作业/OC6_字典&集合课后作业/File";
//    NSString *str = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
//    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
//    NSArray *arr = [str componentsSeparatedByString:@"\n"];
////    NSLog(@"%@", arr);
//    for (NSInteger i = 0; i < [arr count]; i++) {
//        NSArray *temp = [[arr objectAtIndex:i] componentsSeparatedByString:@" #"];
////        NSLog(@"%@", temp);
//        [dic setObject:[temp objectAtIndex:1] forKey:[temp objectAtIndex:0]];
//    }
////    NSLog(@"%@", dic.allKeys);
//    
//    
//    // 取出所有key, 升序排序
//   NSArray *key = [[dic allKeys] sortedArrayUsingSelector:@selector(compare:)];
//    NSLog(@"%@", key);
////    NSLog(@"%ld", key.count);
//    
////    // 取出所有value, 按照排序后的key排列
////    
////            //排序后的字典
//            NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];
//    
//            for (NSInteger i = 0; i < key.count; i ++) {
//                //排序后的键值对放到新的字典中
//                [tempDic setObject:[dic objectForKey:[key objectAtIndex:i]] forKey:[key objectAtIndex:i]];
//            }
//    NSLog(@"%ld", tempDic.allKeys.count);
    
    
    
    
    

}


